#ifndef _CWIZARD_H_
#define _CWIZARD_H_

#include <buola/gui/cwindow.h>
#include <buola/image/cpicture.h>

namespace buola { namespace gui {

class CWizardPage
{
public:
    CWizardPage(int pPos,TID pID,const std::wstring &pText,const img::CPicture& pImage=img::CPicture(),
                const PWindow &pWindow=nullptr)
    {
        mID=pID;
        mPos=pPos;
        mEnabled=true;
        mText=pText;
        mImage=pImage;
        mSelected=false;
        mWindow=pWindow;
        mShown=false;
    }

    int mPos;
    bool mEnabled;
    TID mID;
    std::wstring mText;
    img::CPicture mImage;
    bool mSelected;
    PWindow mWindow;
    bool mShown;
};

class CWizard : public CWindow
{
public:
    CWizard();
    ~CWizard();

    void SetNext(bool);
    void SetPrev(bool);
    void SetCancel(bool);
    void SetFinish(bool);

    void Next();
    void Prev();
    void Finish();
    void Cancel();

    CWizardPage *GetPage(int i)
    {
        return mPages[i];
    }

    CWizardPage *GetCurPage()
    {
        if(mCurPage>=0) return mPages[mCurPage];
        return nullptr;
    }

    void AddPage(TID,const std::wstring&,const img::CPicture& =img::CPicture(),CWindow* =nullptr);
    void InsertPage(int,TID,const std::wstring&,const img::CPicture& =img::CPicture(),CWindow* =nullptr);
    void RemovePage(CWizardPage *pPage); 
    void ShowPage(CWizardPage*);

    int GetResult()         {   return mResult;     }

protected:
    void EnableButtons();
    void Shape();

protected:
////////////////// Asking if we can change page //////////////////
    virtual bool CanNext()      {   return true;    }
    virtual bool CanPrev()      {   return true;    }
    virtual bool CanFinish()    {   return true;    }
    virtual bool CanCancel()    {   return true;    }

public:
////////////// Event handling //////////////
    virtual void OnExpose(const CExposeEvent &pE);

    virtual void OnPageNeeded(CWizardPage*) {}
    virtual void OnPageChanged(CWizardPage*,CWizardPage*) {}
    
    virtual void OnFinish() {}
    virtual void OnCancel() {}

protected:
    bool mNextSet,mPrevSet,mFinishSet,mCancelSet;
    PButton mNext,mPrev,mFinish,mCancel;
    img::PFont mFont;

    int mResult;
    std::vector<CWizardPage*> mPages;
    int mCurPage;
    CImageBox *mImageBox;

////////////////// static data //////////////////
};

/*namespace gui*/ } /*namespace buola*/ }

#endif
